/**
 * Copyright: Copyright (c)2011
 * Company: 易宝支付(YeePay)
 */
package net.loyintean.pearlshell.validation.rule;

import net.loyintean.pearlshell.validation.IValidRuleConfig;
import net.loyintean.pearlshell.validation.rule.AbstractStringValidRuleImpl;

/** string长度恰好等于
 * 
 * @author：jun.lin@yeepay.com
 * @since：2015年1月2日 下午11:21:05
 * @version: */
class StringLengthEqualsValidRuleImpl extends AbstractStringValidRuleImpl {

	/** @see net.loyintean.pearlshell.validation.IValidRule
	 *      #errorMsg(net.loyintean.pearlshell.validation.IValidRuleConfig) */
	@Override
	public String errorMsg(IValidRuleConfig arg0) {
		return "长度必须为" + arg0.validParam()[0] + "位";
	}

	/** @see net.loyintean.pearlshell.validation.rule.AbstractStringValidRuleImpl#validString(java.lang.String,
	 *      net.loyintean.pearlshell.validation.IValidRuleConfig) */
	@Override
	protected boolean validString(String arg0, IValidRuleConfig arg1) {

		int length = (Integer) arg1.validParam()[0];

		return length == arg0.length();
	}
}
